<template>
  <div class="countBox">
    <button class="minus" @click="handleSub">-</button>
    <input class="input" type="text" :value="value">
    <button class="add" @click="handleAdd">+</button>
  </div>

</template>

<script>
export default {
  props: {
    value: {
      type: Number,
      default: 1
    }
  },
  methods: {
    handleSub () {
      if (this.value <= 1) {
        return
      }
      this.$emit('input', this.value - 1)
    },
    handleAdd () {
      this.$emit('input', this.value + 1)
    }
  }
}
</script>

<style lang="less" scoped>
    .countBox {
        width: 110px;
        display: flex;
        .add,
        .minus {
            width: 30px;
            height: 30px;
            outline: none;
            border: none;
            background-color: #efefef;
        }
        .input {
            width: 40px;
            height: 30px;
            outline: none;
            border: none;
            margin: 0 5px;
            background-color: #efefef;
            text-align: center;
            line-height: 30px;

        }
    }
</style>
